package com.changgou.config.service.impl;

import com.changgou.config.dao.FreightTemplateMapper;
import com.changgou.config.service.FreightTemplateService;
import com.changgou.config.pojo.FreightTemplate;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.Map;

@Service
public class FreightTemplateServiceImpl implements FreightTemplateService {

    @Autowired
    private FreightTemplateMapper freightTemplateMapper;

    /**
     * 分页查询运费模板
     * @param current
     * @param pageSize
     * @return
     */
    @Override
    public Page<FreightTemplate> freightTemplate(int current, int pageSize) {
        PageHelper.startPage(current,pageSize);
        Page<FreightTemplate> freightTemplates = (Page<FreightTemplate>) freightTemplateMapper.selectAll();
        return freightTemplates;
    }

    /**
     * 新增运模板
     * @param freightTemplate
     */
    @Override
    public void addFreightTemplate(FreightTemplate freightTemplate) {
        freightTemplateMapper.insertSelective(freightTemplate);
    }

    /**
     * 删除运费模板
     * @param id
     */
    @Override
    public void deleteFreightTemplate(int id) {
        freightTemplateMapper.deleteByPrimaryKey(id);
    }
}
